package com.webchat.admin.controller;


import com.webchat.admin.service.MessageCardTemplateService;
import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.common.helper.SessionHelper;
import com.webchat.domain.vo.request.MessageCardTemplateRequestVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin-service/message-card/template")
public class MessageCardTemplateController {


    @Autowired
    private MessageCardTemplateService messageCardTemplateService;

    /**
     * 创建或者更新服务号消息模版配置
     *
     * @param templateRequest
     * @return
     */
    @PostMapping("/save")
    public APIResponseBean<String> save(@RequestBody MessageCardTemplateRequestVO templateRequest) {

        templateRequest.validateTemplateParam();

        String userId = SessionHelper.getCurrentUserId();
        templateRequest.setOperator(userId);
        return APIResponseBeanUtil.success(messageCardTemplateService.save(templateRequest));
    }


}
